package helper;


import java.util.concurrent.CountDownLatch;

public class CountDownLatchDemo {
    public static void main(String[] args) throws InterruptedException {
        //倒计时 总数6
        CountDownLatch countDownLatch = new CountDownLatch(6);

        for(int i = 0 ; i < 6 ; i++){
            new Thread(()->{
                System.out.println(Thread.currentThread().getName()+"thread!");
                //-1
                countDownLatch.countDown();
            },String.valueOf(i)).start();
        }

        //等待计数器归零，然后再向下执行
        countDownLatch.await();

        System.out.println("计数器已归零！");
    }
}
